/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package l1j.server.server.clientpackets;

import l1j.server.echo.ClientThread;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.templates.L1BookMark;

import java.util.logging.Level;
import java.util.logging.Logger;
/**
 * 要求刪除記憶座標
 *
 */

/**
 * 處理收到由客戶端傳來刪除書籤的封包
 */
public class C_DeleteBookmark extends ClientBasePacket {
	private static final String C_DETELE_BOOKMARK = "[C] C_DeleteBookmark";
	private static final Logger _log = Logger.getLogger(C_DeleteBookmark.class.getName());
	@Override
	public String getType() {
		return C_DETELE_BOOKMARK;
	}

	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);
		final L1PcInstance pc = client.getActiveChar();
		if (pc == null) {
			return;
		}
		final String bookmarkname = this.readS();
		if(bookmarkname == null){
			return;
		}
		if (!bookmarkname.isEmpty()) {//opqlo 3.53記憶座標顯示
		L1BookMark.deleteBookmark(pc, bookmarkname);

		}
		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}
}
